/*
Algorithm Name: Keccak
Authors: Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche
Date: January 9, 2009

This code, originally by Guido Bertoni, Joan Daemen, Michaël Peeters and
Gilles Van Assche as a part of the SHA-3 submission, is hereby put in the
public domain. It is given as is, without any guarantee.

For more information, feedback or questions, please refer to our website:
http://keccak.noekeon.org/
*/

#define declareABCDE \
    UINT32 Aba0, Abe0, Abi0, Abo0, Abu0; \
    UINT32 Aba1, Abe1, Abi1, Abo1, Abu1; \
    UINT32 Aga0, Age0, Agi0, Ago0, Agu0; \
    UINT32 Aga1, Age1, Agi1, Ago1, Agu1; \
    UINT32 Aka0, Ake0, Aki0, Ako0, Aku0; \
    UINT32 Aka1, Ake1, Aki1, Ako1, Aku1; \
    UINT32 Ama0, Ame0, Ami0, Amo0, Amu0; \
    UINT32 Ama1, Ame1, Ami1, Amo1, Amu1; \
    UINT32 Asa0, Ase0, Asi0, Aso0, Asu0; \
    UINT32 Asa1, Ase1, Asi1, Aso1, Asu1; \
    UINT32 Bba0, Bbe0, Bbi0, Bbo0, Bbu0; \
    UINT32 Bba1, Bbe1, Bbi1, Bbo1, Bbu1; \
    UINT32 Bga0, Bge0, Bgi0, Bgo0, Bgu0; \
    UINT32 Bga1, Bge1, Bgi1, Bgo1, Bgu1; \
    UINT32 Bka0, Bke0, Bki0, Bko0, Bku0; \
    UINT32 Bka1, Bke1, Bki1, Bko1, Bku1; \
    UINT32 Bma0, Bme0, Bmi0, Bmo0, Bmu0; \
    UINT32 Bma1, Bme1, Bmi1, Bmo1, Bmu1; \
    UINT32 Bsa0, Bse0, Bsi0, Bso0, Bsu0; \
    UINT32 Bsa1, Bse1, Bsi1, Bso1, Bsu1; \
    UINT32 Ca0, Ce0, Ci0, Co0, Cu0; \
    UINT32 Ca1, Ce1, Ci1, Co1, Cu1; \
    UINT32 Da0, De0, Di0, Do0, Du0; \
    UINT32 Da1, De1, Di1, Do1, Du1; \
    UINT32 Eba0, Ebe0, Ebi0, Ebo0, Ebu0; \
    UINT32 Eba1, Ebe1, Ebi1, Ebo1, Ebu1; \
    UINT32 Ega0, Ege0, Egi0, Ego0, Egu0; \
    UINT32 Ega1, Ege1, Egi1, Ego1, Egu1; \
    UINT32 Eka0, Eke0, Eki0, Eko0, Eku0; \
    UINT32 Eka1, Eke1, Eki1, Eko1, Eku1; \
    UINT32 Ema0, Eme0, Emi0, Emo0, Emu0; \
    UINT32 Ema1, Eme1, Emi1, Emo1, Emu1; \
    UINT32 Esa0, Ese0, Esi0, Eso0, Esu0; \
    UINT32 Esa1, Ese1, Esi1, Eso1, Esu1; \

#define copy(X, Y) \
    X##ba0 = Y##ba0; \
    X##ba1 = Y##ba1; \
    X##be0 = Y##be0; \
    X##be1 = Y##be1; \
    X##bi0 = Y##bi0; \
    X##bi1 = Y##bi1; \
    X##bo0 = Y##bo0; \
    X##bo1 = Y##bo1; \
    X##bu0 = Y##bu0; \
    X##bu1 = Y##bu1; \
    X##ga0 = Y##ga0; \
    X##ga1 = Y##ga1; \
    X##ge0 = Y##ge0; \
    X##ge1 = Y##ge1; \
    X##gi0 = Y##gi0; \
    X##gi1 = Y##gi1; \
    X##go0 = Y##go0; \
    X##go1 = Y##go1; \
    X##gu0 = Y##gu0; \
    X##gu1 = Y##gu1; \
    X##ka0 = Y##ka0; \
    X##ka1 = Y##ka1; \
    X##ke0 = Y##ke0; \
    X##ke1 = Y##ke1; \
    X##ki0 = Y##ki0; \
    X##ki1 = Y##ki1; \
    X##ko0 = Y##ko0; \
    X##ko1 = Y##ko1; \
    X##ku0 = Y##ku0; \
    X##ku1 = Y##ku1; \
    X##ma0 = Y##ma0; \
    X##ma1 = Y##ma1; \
    X##me0 = Y##me0; \
    X##me1 = Y##me1; \
    X##mi0 = Y##mi0; \
    X##mi1 = Y##mi1; \
    X##mo0 = Y##mo0; \
    X##mo1 = Y##mo1; \
    X##mu0 = Y##mu0; \
    X##mu1 = Y##mu1; \
    X##sa0 = Y##sa0; \
    X##sa1 = Y##sa1; \
    X##se0 = Y##se0; \
    X##se1 = Y##se1; \
    X##si0 = Y##si0; \
    X##si1 = Y##si1; \
    X##so0 = Y##so0; \
    X##so1 = Y##so1; \
    X##su0 = Y##su0; \
    X##su1 = Y##su1; \

#define copyFromState(X, state) \
    X##ba0 = state[ 0]; \
    X##ba1 = state[ 1]; \
    X##be0 = state[ 2]; \
    X##be1 = state[ 3]; \
    X##bi0 = state[ 4]; \
    X##bi1 = state[ 5]; \
    X##bo0 = state[ 6]; \
    X##bo1 = state[ 7]; \
    X##bu0 = state[ 8]; \
    X##bu1 = state[ 9]; \
    X##ga0 = state[10]; \
    X##ga1 = state[11]; \
    X##ge0 = state[12]; \
    X##ge1 = state[13]; \
    X##gi0 = state[14]; \
    X##gi1 = state[15]; \
    X##go0 = state[16]; \
    X##go1 = state[17]; \
    X##gu0 = state[18]; \
    X##gu1 = state[19]; \
    X##ka0 = state[20]; \
    X##ka1 = state[21]; \
    X##ke0 = state[22]; \
    X##ke1 = state[23]; \
    X##ki0 = state[24]; \
    X##ki1 = state[25]; \
    X##ko0 = state[26]; \
    X##ko1 = state[27]; \
    X##ku0 = state[28]; \
    X##ku1 = state[29]; \
    X##ma0 = state[30]; \
    X##ma1 = state[31]; \
    X##me0 = state[32]; \
    X##me1 = state[33]; \
    X##mi0 = state[34]; \
    X##mi1 = state[35]; \
    X##mo0 = state[36]; \
    X##mo1 = state[37]; \
    X##mu0 = state[38]; \
    X##mu1 = state[39]; \
    X##sa0 = state[40]; \
    X##sa1 = state[41]; \
    X##se0 = state[42]; \
    X##se1 = state[43]; \
    X##si0 = state[44]; \
    X##si1 = state[45]; \
    X##so0 = state[46]; \
    X##so1 = state[47]; \
    X##su0 = state[48]; \
    X##su1 = state[49]; \

#define copyToState(state, X) \
    state[ 0] = X##ba0; \
    state[ 1] = X##ba1; \
    state[ 2] = X##be0; \
    state[ 3] = X##be1; \
    state[ 4] = X##bi0; \
    state[ 5] = X##bi1; \
    state[ 6] = X##bo0; \
    state[ 7] = X##bo1; \
    state[ 8] = X##bu0; \
    state[ 9] = X##bu1; \
    state[10] = X##ga0; \
    state[11] = X##ga1; \
    state[12] = X##ge0; \
    state[13] = X##ge1; \
    state[14] = X##gi0; \
    state[15] = X##gi1; \
    state[16] = X##go0; \
    state[17] = X##go1; \
    state[18] = X##gu0; \
    state[19] = X##gu1; \
    state[20] = X##ka0; \
    state[21] = X##ka1; \
    state[22] = X##ke0; \
    state[23] = X##ke1; \
    state[24] = X##ki0; \
    state[25] = X##ki1; \
    state[26] = X##ko0; \
    state[27] = X##ko1; \
    state[28] = X##ku0; \
    state[29] = X##ku1; \
    state[30] = X##ma0; \
    state[31] = X##ma1; \
    state[32] = X##me0; \
    state[33] = X##me1; \
    state[34] = X##mi0; \
    state[35] = X##mi1; \
    state[36] = X##mo0; \
    state[37] = X##mo1; \
    state[38] = X##mu0; \
    state[39] = X##mu1; \
    state[40] = X##sa0; \
    state[41] = X##sa1; \
    state[42] = X##se0; \
    state[43] = X##se1; \
    state[44] = X##si0; \
    state[45] = X##si1; \
    state[46] = X##so0; \
    state[47] = X##so1; \
    state[48] = X##su0; \
    state[49] = X##su1; \

#define thetaPiRhoChiIotaPrepareTheta(i) \
    Da0 = Cu0^ROL32(Ce1, 1); \
    Da1 = Cu1^Ce0; \
    De0 = Ca0^ROL32(Ci1, 1); \
    De1 = Ca1^Ci0; \
    Di0 = Ce0^ROL32(Co1, 1); \
    Di1 = Ce1^Co0; \
    Do0 = Ci0^ROL32(Cu1, 1); \
    Do1 = Ci1^Cu0; \
    Du0 = Co0^ROL32(Ca1, 1); \
    Du1 = Co1^Ca0; \
\
    Aba0 ^= Da0; \
    Bba0 = Aba0; \
    Age0 ^= De0; \
    Bbe0 = ROL32(Age0, 22); \
    Aki1 ^= Di1; \
    Bbi0 = ROL32(Aki1, 22); \
    Eba0 =  Bba0 ^ ((~Bbe0)&  Bbi0 ); \
    Eba0 ^= KeccakRoundConstants0[i]; \
    Ca0 = Eba0; \
    Amo1 ^= Do1; \
    Bbo0 = ROL32(Amo1, 11); \
    Ebe0 =  Bbe0 ^ ((~Bbi0)&  Bbo0 ); \
    Ce0 = Ebe0; \
    Asu0 ^= Du0; \
    Bbu0 = ROL32(Asu0,  7); \
    Ebi0 =  Bbi0 ^ ((~Bbo0)&  Bbu0 ); \
    Ci0 = Ebi0; \
    Ebo0 =  Bbo0 ^ ((~Bbu0)&  Bba0 ); \
    Co0 = Ebo0; \
    Ebu0 =  Bbu0 ^ ((~Bba0)&  Bbe0 ); \
    Cu0 = Ebu0; \
\
    Aba1 ^= Da1; \
    Bba1 = Aba1; \
    Age1 ^= De1; \
    Bbe1 = ROL32(Age1, 22); \
    Aki0 ^= Di0; \
    Bbi1 = ROL32(Aki0, 21); \
    Eba1 =  Bba1 ^ ((~Bbe1)&  Bbi1 ); \
    Eba1 ^= KeccakRoundConstants1[i]; \
    Ca1 = Eba1; \
    Amo0 ^= Do0; \
    Bbo1 = ROL32(Amo0, 10); \
    Ebe1 =  Bbe1 ^ ((~Bbi1)&  Bbo1 ); \
    Ce1 = Ebe1; \
    Asu1 ^= Du1; \
    Bbu1 = ROL32(Asu1,  7); \
    Ebi1 =  Bbi1 ^ ((~Bbo1)&  Bbu1 ); \
    Ci1 = Ebi1; \
    Ebo1 =  Bbo1 ^ ((~Bbu1)&  Bba1 ); \
    Co1 = Ebo1; \
    Ebu1 =  Bbu1 ^ ((~Bba1)&  Bbe1 ); \
    Cu1 = Ebu1; \
\
    Abo0 ^= Do0; \
    Bga0 = ROL32(Abo0, 14); \
    Agu0 ^= Du0; \
    Bge0 = ROL32(Agu0, 10); \
    Aka1 ^= Da1; \
    Bgi0 = ROL32(Aka1,  2); \
    Ega0 =  Bga0 ^ ((~Bge0)&  Bgi0 ); \
    Ca0 ^= Ega0; \
    Ame1 ^= De1; \
    Bgo0 = ROL32(Ame1, 23); \
    Ege0 =  Bge0 ^ ((~Bgi0)&  Bgo0 ); \
    Ce0 ^= Ege0; \
    Asi1 ^= Di1; \
    Bgu0 = ROL32(Asi1, 31); \
    Egi0 =  Bgi0 ^ ((~Bgo0)&  Bgu0 ); \
    Ci0 ^= Egi0; \
    Ego0 =  Bgo0 ^ ((~Bgu0)&  Bga0 ); \
    Co0 ^= Ego0; \
    Egu0 =  Bgu0 ^ ((~Bga0)&  Bge0 ); \
    Cu0 ^= Egu0; \
\
    Abo1 ^= Do1; \
    Bga1 = ROL32(Abo1, 14); \
    Agu1 ^= Du1; \
    Bge1 = ROL32(Agu1, 10); \
    Aka0 ^= Da0; \
    Bgi1 = ROL32(Aka0,  1); \
    Ega1 =  Bga1 ^ ((~Bge1)&  Bgi1 ); \
    Ca1 ^= Ega1; \
    Ame0 ^= De0; \
    Bgo1 = ROL32(Ame0, 22); \
    Ege1 =  Bge1 ^ ((~Bgi1)&  Bgo1 ); \
    Ce1 ^= Ege1; \
    Asi0 ^= Di0; \
    Bgu1 = ROL32(Asi0, 30); \
    Egi1 =  Bgi1 ^ ((~Bgo1)&  Bgu1 ); \
    Ci1 ^= Egi1; \
    Ego1 =  Bgo1 ^ ((~Bgu1)&  Bga1 ); \
    Co1 ^= Ego1; \
    Egu1 =  Bgu1 ^ ((~Bga1)&  Bge1 ); \
    Cu1 ^= Egu1; \
\
    Abe1 ^= De1; \
    Bka0 = ROL32(Abe1,  1); \
    Agi0 ^= Di0; \
    Bke0 = ROL32(Agi0,  3); \
    Ako1 ^= Do1; \
    Bki0 = ROL32(Ako1, 13); \
    Eka0 =  Bka0 ^ ((~Bke0)&  Bki0 ); \
    Ca0 ^= Eka0; \
    Amu0 ^= Du0; \
    Bko0 = ROL32(Amu0,  4); \
    Eke0 =  Bke0 ^ ((~Bki0)&  Bko0 ); \
    Ce0 ^= Eke0; \
    Asa0 ^= Da0; \
    Bku0 = ROL32(Asa0,  9); \
    Eki0 =  Bki0 ^ ((~Bko0)&  Bku0 ); \
    Ci0 ^= Eki0; \
    Eko0 =  Bko0 ^ ((~Bku0)&  Bka0 ); \
    Co0 ^= Eko0; \
    Eku0 =  Bku0 ^ ((~Bka0)&  Bke0 ); \
    Cu0 ^= Eku0; \
\
    Abe0 ^= De0; \
    Bka1 = Abe0; \
    Agi1 ^= Di1; \
    Bke1 = ROL32(Agi1,  3); \
    Ako0 ^= Do0; \
    Bki1 = ROL32(Ako0, 12); \
    Eka1 =  Bka1 ^ ((~Bke1)&  Bki1 ); \
    Ca1 ^= Eka1; \
    Amu1 ^= Du1; \
    Bko1 = ROL32(Amu1,  4); \
    Eke1 =  Bke1 ^ ((~Bki1)&  Bko1 ); \
    Ce1 ^= Eke1; \
    Asa1 ^= Da1; \
    Bku1 = ROL32(Asa1,  9); \
    Eki1 =  Bki1 ^ ((~Bko1)&  Bku1 ); \
    Ci1 ^= Eki1; \
    Eko1 =  Bko1 ^ ((~Bku1)&  Bka1 ); \
    Co1 ^= Eko1; \
    Eku1 =  Bku1 ^ ((~Bka1)&  Bke1 ); \
    Cu1 ^= Eku1; \
\
    Abu1 ^= Du1; \
    Bma0 = ROL32(Abu1, 14); \
    Aga0 ^= Da0; \
    Bme0 = ROL32(Aga0, 18); \
    Ake0 ^= De0; \
    Bmi0 = ROL32(Ake0,  5); \
    Ema0 =  Bma0 ^ ((~Bme0)&  Bmi0 ); \
    Ca0 ^= Ema0; \
    Ami1 ^= Di1; \
    Bmo0 = ROL32(Ami1,  8); \
    Eme0 =  Bme0 ^ ((~Bmi0)&  Bmo0 ); \
    Ce0 ^= Eme0; \
    Aso0 ^= Do0; \
    Bmu0 = ROL32(Aso0, 28); \
    Emi0 =  Bmi0 ^ ((~Bmo0)&  Bmu0 ); \
    Ci0 ^= Emi0; \
    Emo0 =  Bmo0 ^ ((~Bmu0)&  Bma0 ); \
    Co0 ^= Emo0; \
    Emu0 =  Bmu0 ^ ((~Bma0)&  Bme0 ); \
    Cu0 ^= Emu0; \
\
    Abu0 ^= Du0; \
    Bma1 = ROL32(Abu0, 13); \
    Aga1 ^= Da1; \
    Bme1 = ROL32(Aga1, 18); \
    Ake1 ^= De1; \
    Bmi1 = ROL32(Ake1,  5); \
    Ema1 =  Bma1 ^ ((~Bme1)&  Bmi1 ); \
    Ca1 ^= Ema1; \
    Ami0 ^= Di0; \
    Bmo1 = ROL32(Ami0,  7); \
    Eme1 =  Bme1 ^ ((~Bmi1)&  Bmo1 ); \
    Ce1 ^= Eme1; \
    Aso1 ^= Do1; \
    Bmu1 = ROL32(Aso1, 28); \
    Emi1 =  Bmi1 ^ ((~Bmo1)&  Bmu1 ); \
    Ci1 ^= Emi1; \
    Emo1 =  Bmo1 ^ ((~Bmu1)&  Bma1 ); \
    Co1 ^= Emo1; \
    Emu1 =  Bmu1 ^ ((~Bma1)&  Bme1 ); \
    Cu1 ^= Emu1; \
\
    Abi0 ^= Di0; \
    Bsa0 = ROL32(Abi0, 31); \
    Ago1 ^= Do1; \
    Bse0 = ROL32(Ago1, 28); \
    Aku1 ^= Du1; \
    Bsi0 = ROL32(Aku1, 20); \
    Esa0 =  Bsa0 ^ ((~Bse0)&  Bsi0 ); \
    Ca0 ^= Esa0; \
    Ama1 ^= Da1; \
    Bso0 = ROL32(Ama1, 21); \
    Ese0 =  Bse0 ^ ((~Bsi0)&  Bso0 ); \
    Ce0 ^= Ese0; \
    Ase0 ^= De0; \
    Bsu0 = ROL32(Ase0,  1); \
    Esi0 =  Bsi0 ^ ((~Bso0)&  Bsu0 ); \
    Ci0 ^= Esi0; \
    Eso0 =  Bso0 ^ ((~Bsu0)&  Bsa0 ); \
    Co0 ^= Eso0; \
    Esu0 =  Bsu0 ^ ((~Bsa0)&  Bse0 ); \
    Cu0 ^= Esu0; \
\
    Abi1 ^= Di1; \
    Bsa1 = ROL32(Abi1, 31); \
    Ago0 ^= Do0; \
    Bse1 = ROL32(Ago0, 27); \
    Aku0 ^= Du0; \
    Bsi1 = ROL32(Aku0, 19); \
    Esa1 =  Bsa1 ^ ((~Bse1)&  Bsi1 ); \
    Ca1 ^= Esa1; \
    Ama0 ^= Da0; \
    Bso1 = ROL32(Ama0, 20); \
    Ese1 =  Bse1 ^ ((~Bsi1)&  Bso1 ); \
    Ce1 ^= Ese1; \
    Ase1 ^= De1; \
    Bsu1 = ROL32(Ase1,  1); \
    Esi1 =  Bsi1 ^ ((~Bso1)&  Bsu1 ); \
    Ci1 ^= Esi1; \
    Eso1 =  Bso1 ^ ((~Bsu1)&  Bsa1 ); \
    Co1 ^= Eso1; \
    Esu1 =  Bsu1 ^ ((~Bsa1)&  Bse1 ); \
    Cu1 ^= Esu1; \
\
    copy(A, E)

#define thetaPiRhoAltchiIotaPrepareTheta(i) \
    Da0 = Cu0^ROL32(Ce1, 1); \
    Da1 = Cu1^Ce0; \
    De0 = Ca0^ROL32(Ci1, 1); \
    De1 = Ca1^Ci0; \
    Di0 = Ce0^ROL32(Co1, 1); \
    Di1 = Ce1^Co0; \
    Do0 = Ci0^ROL32(Cu1, 1); \
    Do1 = Ci1^Cu0; \
    Du0 = Co0^ROL32(Ca1, 1); \
    Du1 = Co1^Ca0; \
\
    Aba0 ^= Da0; \
    Bba0 = Aba0; \
    Age0 ^= De0; \
    Bbe0 = ROL32(Age0, 22); \
    Aki1 ^= Di1; \
    Bbi0 = ROL32(Aki1, 22); \
    Eba0 =  Bba0 ^ (  Bbe0 |  Bbi0 ); \
    Eba0 ^= KeccakRoundConstants0[i]; \
    Ca0 = Eba0; \
    Amo1 ^= Do1; \
    Bbo0 = ROL32(Amo1, 11); \
    Ebe0 =  Bbe0 ^ ((~Bbi0)|  Bbo0 ); \
    Ce0 = Ebe0; \
    Asu0 ^= Du0; \
    Bbu0 = ROL32(Asu0,  7); \
    Ebi0 =  Bbi0 ^ (  Bbo0 &  Bbu0 ); \
    Ci0 = Ebi0; \
    Ebo0 =  Bbo0 ^ (  Bbu0 |  Bba0 ); \
    Co0 = Ebo0; \
    Ebu0 =  Bbu0 ^ (  Bba0 &  Bbe0 ); \
    Cu0 = Ebu0; \
\
    Aba1 ^= Da1; \
    Bba1 = Aba1; \
    Age1 ^= De1; \
    Bbe1 = ROL32(Age1, 22); \
    Aki0 ^= Di0; \
    Bbi1 = ROL32(Aki0, 21); \
    Eba1 =  Bba1 ^ (  Bbe1 |  Bbi1 ); \
    Eba1 ^= KeccakRoundConstants1[i]; \
    Ca1 = Eba1; \
    Amo0 ^= Do0; \
    Bbo1 = ROL32(Amo0, 10); \
    Ebe1 =  Bbe1 ^ ((~Bbi1)|  Bbo1 ); \
    Ce1 = Ebe1; \
    Asu1 ^= Du1; \
    Bbu1 = ROL32(Asu1,  7); \
    Ebi1 =  Bbi1 ^ (  Bbo1 &  Bbu1 ); \
    Ci1 = Ebi1; \
    Ebo1 =  Bbo1 ^ (  Bbu1 |  Bba1 ); \
    Co1 = Ebo1; \
    Ebu1 =  Bbu1 ^ (  Bba1 &  Bbe1 ); \
    Cu1 = Ebu1; \
\
    Abo0 ^= Do0; \
    Bga0 = ROL32(Abo0, 14); \
    Agu0 ^= Du0; \
    Bge0 = ROL32(Agu0, 10); \
    Aka1 ^= Da1; \
    Bgi0 = ROL32(Aka1,  2); \
    Ega0 =  Bga0 ^ (  Bge0 |  Bgi0 ); \
    Ca0 ^= Ega0; \
    Ame1 ^= De1; \
    Bgo0 = ROL32(Ame1, 23); \
    Ege0 =  Bge0 ^ (  Bgi0 &  Bgo0 ); \
    Ce0 ^= Ege0; \
    Asi1 ^= Di1; \
    Bgu0 = ROL32(Asi1, 31); \
    Egi0 =  Bgi0 ^ (  Bgo0 |(~Bgu0)); \
    Ci0 ^= Egi0; \
    Ego0 =  Bgo0 ^ (  Bgu0 |  Bga0 ); \
    Co0 ^= Ego0; \
    Egu0 =  Bgu0 ^ (  Bga0 &  Bge0 ); \
    Cu0 ^= Egu0; \
\
    Abo1 ^= Do1; \
    Bga1 = ROL32(Abo1, 14); \
    Agu1 ^= Du1; \
    Bge1 = ROL32(Agu1, 10); \
    Aka0 ^= Da0; \
    Bgi1 = ROL32(Aka0,  1); \
    Ega1 =  Bga1 ^ (  Bge1 |  Bgi1 ); \
    Ca1 ^= Ega1; \
    Ame0 ^= De0; \
    Bgo1 = ROL32(Ame0, 22); \
    Ege1 =  Bge1 ^ (  Bgi1 &  Bgo1 ); \
    Ce1 ^= Ege1; \
    Asi0 ^= Di0; \
    Bgu1 = ROL32(Asi0, 30); \
    Egi1 =  Bgi1 ^ (  Bgo1 |(~Bgu1)); \
    Ci1 ^= Egi1; \
    Ego1 =  Bgo1 ^ (  Bgu1 |  Bga1 ); \
    Co1 ^= Ego1; \
    Egu1 =  Bgu1 ^ (  Bga1 &  Bge1 ); \
    Cu1 ^= Egu1; \
\
    Abe1 ^= De1; \
    Bka0 = ROL32(Abe1,  1); \
    Agi0 ^= Di0; \
    Bke0 = ROL32(Agi0,  3); \
    Ako1 ^= Do1; \
    Bki0 = ROL32(Ako1, 13); \
    Eka0 =  Bka0 ^ (  Bke0 |  Bki0 ); \
    Ca0 ^= Eka0; \
    Amu0 ^= Du0; \
    Bko0 = ROL32(Amu0,  4); \
    Eke0 =  Bke0 ^ (  Bki0 &  Bko0 ); \
    Ce0 ^= Eke0; \
    Asa0 ^= Da0; \
    Bku0 = ROL32(Asa0,  9); \
    Eki0 =  Bki0 ^ ((~Bko0)&  Bku0 ); \
    Ci0 ^= Eki0; \
    Eko0 = ~Bko0 ^ (  Bku0 |  Bka0 ); \
    Co0 ^= Eko0; \
    Eku0 =  Bku0 ^ (  Bka0 &  Bke0 ); \
    Cu0 ^= Eku0; \
\
    Abe0 ^= De0; \
    Bka1 = Abe0; \
    Agi1 ^= Di1; \
    Bke1 = ROL32(Agi1,  3); \
    Ako0 ^= Do0; \
    Bki1 = ROL32(Ako0, 12); \
    Eka1 =  Bka1 ^ (  Bke1 |  Bki1 ); \
    Ca1 ^= Eka1; \
    Amu1 ^= Du1; \
    Bko1 = ROL32(Amu1,  4); \
    Eke1 =  Bke1 ^ (  Bki1 &  Bko1 ); \
    Ce1 ^= Eke1; \
    Asa1 ^= Da1; \
    Bku1 = ROL32(Asa1,  9); \
    Eki1 =  Bki1 ^ ((~Bko1)&  Bku1 ); \
    Ci1 ^= Eki1; \
    Eko1 = ~Bko1 ^ (  Bku1 |  Bka1 ); \
    Co1 ^= Eko1; \
    Eku1 =  Bku1 ^ (  Bka1 &  Bke1 ); \
    Cu1 ^= Eku1; \
\
    Abu1 ^= Du1; \
    Bma0 = ROL32(Abu1, 14); \
    Aga0 ^= Da0; \
    Bme0 = ROL32(Aga0, 18); \
    Ake0 ^= De0; \
    Bmi0 = ROL32(Ake0,  5); \
    Ema0 =  Bma0 ^ (  Bme0 &  Bmi0 ); \
    Ca0 ^= Ema0; \
    Ami1 ^= Di1; \
    Bmo0 = ROL32(Ami1,  8); \
    Eme0 =  Bme0 ^ (  Bmi0 |  Bmo0 ); \
    Ce0 ^= Eme0; \
    Aso0 ^= Do0; \
    Bmu0 = ROL32(Aso0, 28); \
    Emi0 =  Bmi0 ^ ((~Bmo0)|  Bmu0 ); \
    Ci0 ^= Emi0; \
    Emo0 = ~Bmo0 ^ (  Bmu0 &  Bma0 ); \
    Co0 ^= Emo0; \
    Emu0 =  Bmu0 ^ (  Bma0 |  Bme0 ); \
    Cu0 ^= Emu0; \
\
    Abu0 ^= Du0; \
    Bma1 = ROL32(Abu0, 13); \
    Aga1 ^= Da1; \
    Bme1 = ROL32(Aga1, 18); \
    Ake1 ^= De1; \
    Bmi1 = ROL32(Ake1,  5); \
    Ema1 =  Bma1 ^ (  Bme1 &  Bmi1 ); \
    Ca1 ^= Ema1; \
    Ami0 ^= Di0; \
    Bmo1 = ROL32(Ami0,  7); \
    Eme1 =  Bme1 ^ (  Bmi1 |  Bmo1 ); \
    Ce1 ^= Eme1; \
    Aso1 ^= Do1; \
    Bmu1 = ROL32(Aso1, 28); \
    Emi1 =  Bmi1 ^ ((~Bmo1)|  Bmu1 ); \
    Ci1 ^= Emi1; \
    Emo1 = ~Bmo1 ^ (  Bmu1 &  Bma1 ); \
    Co1 ^= Emo1; \
    Emu1 =  Bmu1 ^ (  Bma1 |  Bme1 ); \
    Cu1 ^= Emu1; \
\
    Abi0 ^= Di0; \
    Bsa0 = ROL32(Abi0, 31); \
    Ago1 ^= Do1; \
    Bse0 = ROL32(Ago1, 28); \
    Aku1 ^= Du1; \
    Bsi0 = ROL32(Aku1, 20); \
    Esa0 =  Bsa0 ^ ((~Bse0)&  Bsi0 ); \
    Ca0 ^= Esa0; \
    Ama1 ^= Da1; \
    Bso0 = ROL32(Ama1, 21); \
    Ese0 = ~Bse0 ^ (  Bsi0 |  Bso0 ); \
    Ce0 ^= Ese0; \
    Ase0 ^= De0; \
    Bsu0 = ROL32(Ase0,  1); \
    Esi0 =  Bsi0 ^ (  Bso0 &  Bsu0 ); \
    Ci0 ^= Esi0; \
    Eso0 =  Bso0 ^ (  Bsu0 |  Bsa0 ); \
    Co0 ^= Eso0; \
    Esu0 =  Bsu0 ^ (  Bsa0 &  Bse0 ); \
    Cu0 ^= Esu0; \
\
    Abi1 ^= Di1; \
    Bsa1 = ROL32(Abi1, 31); \
    Ago0 ^= Do0; \
    Bse1 = ROL32(Ago0, 27); \
    Aku0 ^= Du0; \
    Bsi1 = ROL32(Aku0, 19); \
    Esa1 =  Bsa1 ^ ((~Bse1)&  Bsi1 ); \
    Ca1 ^= Esa1; \
    Ama0 ^= Da0; \
    Bso1 = ROL32(Ama0, 20); \
    Ese1 = ~Bse1 ^ (  Bsi1 |  Bso1 ); \
    Ce1 ^= Ese1; \
    Ase1 ^= De1; \
    Bsu1 = ROL32(Ase1,  1); \
    Esi1 =  Bsi1 ^ (  Bso1 &  Bsu1 ); \
    Ci1 ^= Esi1; \
    Eso1 =  Bso1 ^ (  Bsu1 |  Bsa1 ); \
    Co1 ^= Eso1; \
    Esu1 =  Bsu1 ^ (  Bsa1 &  Bse1 ); \
    Cu1 ^= Esu1; \
\
    copy(A, E)

#define prepareTheta \
    Ca0 = Aba0^Aga0^Aka0^Ama0^Asa0; \
    Ca1 = Aba1^Aga1^Aka1^Ama1^Asa1; \
    Ce0 = Abe0^Age0^Ake0^Ame0^Ase0; \
    Ce1 = Abe1^Age1^Ake1^Ame1^Ase1; \
    Ci0 = Abi0^Agi0^Aki0^Ami0^Asi0; \
    Ci1 = Abi1^Agi1^Aki1^Ami1^Asi1; \
    Co0 = Abo0^Ago0^Ako0^Amo0^Aso0; \
    Co1 = Abo1^Ago1^Ako1^Amo1^Aso1; \
    Cu0 = Abu0^Agu0^Aku0^Amu0^Asu0; \
    Cu1 = Abu1^Agu1^Aku1^Amu1^Asu1; \

#ifdef UseBebigokimisa

#define firstRound(i) \
    prepareTheta \
    thetaPiRhoAltchiIotaPrepareTheta(i)

#define middleRound(i) \
    thetaPiRhoAltchiIotaPrepareTheta(i)

#else

#define firstRound(i) \
    prepareTheta \
    thetaPiRhoChiIotaPrepareTheta(i)

#define middleRound(i) \
    thetaPiRhoChiIotaPrepareTheta(i)

#endif

#define lastRoundNormal(i) \
    Da0 = Cu0^ROL32(Ce1, 1); \
    Da1 = Cu1^Ce0; \
    De0 = Ca0^ROL32(Ci1, 1); \
    De1 = Ca1^Ci0; \
    Di0 = Ce0^ROL32(Co1, 1); \
    Di1 = Ce1^Co0; \
    Do0 = Ci0^ROL32(Cu1, 1); \
    Do1 = Ci1^Cu0; \
    Du0 = Co0^ROL32(Ca1, 1); \
    Du1 = Co1^Ca0; \
\
    Aba0 ^= Da0; \
    Bba0 = Aba0; \
    Age0 ^= De0; \
    Bbe0 = ROL32(Age0, 22); \
    Aki1 ^= Di1; \
    Bbi0 = ROL32(Aki1, 22); \
    Eba0 =  Bba0 ^ ((~Bbe0)&  Bbi0 ); \
    Eba0 ^= KeccakRoundConstants0[i]; \
    Amo1 ^= Do1; \
    Bbo0 = ROL32(Amo1, 11); \
    Ebe0 =  Bbe0 ^ ((~Bbi0)&  Bbo0 ); \
    Asu0 ^= Du0; \
    Bbu0 = ROL32(Asu0,  7); \
    Ebi0 =  Bbi0 ^ ((~Bbo0)&  Bbu0 ); \
    Ebo0 =  Bbo0 ^ ((~Bbu0)&  Bba0 ); \
    Ebu0 =  Bbu0 ^ ((~Bba0)&  Bbe0 ); \
\
    Aba1 ^= Da1; \
    Bba1 = Aba1; \
    Age1 ^= De1; \
    Bbe1 = ROL32(Age1, 22); \
    Aki0 ^= Di0; \
    Bbi1 = ROL32(Aki0, 21); \
    Eba1 =  Bba1 ^ ((~Bbe1)&  Bbi1 ); \
    Eba1 ^= KeccakRoundConstants1[i]; \
    Amo0 ^= Do0; \
    Bbo1 = ROL32(Amo0, 10); \
    Ebe1 =  Bbe1 ^ ((~Bbi1)&  Bbo1 ); \
    Asu1 ^= Du1; \
    Bbu1 = ROL32(Asu1,  7); \
    Ebi1 =  Bbi1 ^ ((~Bbo1)&  Bbu1 ); \
    Ebo1 =  Bbo1 ^ ((~Bbu1)&  Bba1 ); \
    Ebu1 =  Bbu1 ^ ((~Bba1)&  Bbe1 ); \
\
    Abo0 ^= Do0; \
    Bga0 = ROL32(Abo0, 14); \
    Agu0 ^= Du0; \
    Bge0 = ROL32(Agu0, 10); \
    Aka1 ^= Da1; \
    Bgi0 = ROL32(Aka1,  2); \
    Ega0 =  Bga0 ^ ((~Bge0)&  Bgi0 ); \
    Ame1 ^= De1; \
    Bgo0 = ROL32(Ame1, 23); \
    Ege0 =  Bge0 ^ ((~Bgi0)&  Bgo0 ); \
    Asi1 ^= Di1; \
    Bgu0 = ROL32(Asi1, 31); \
    Egi0 =  Bgi0 ^ ((~Bgo0)&  Bgu0 ); \
    Ego0 =  Bgo0 ^ ((~Bgu0)&  Bga0 ); \
    Egu0 =  Bgu0 ^ ((~Bga0)&  Bge0 ); \
\
    Abo1 ^= Do1; \
    Bga1 = ROL32(Abo1, 14); \
    Agu1 ^= Du1; \
    Bge1 = ROL32(Agu1, 10); \
    Aka0 ^= Da0; \
    Bgi1 = ROL32(Aka0,  1); \
    Ega1 =  Bga1 ^ ((~Bge1)&  Bgi1 ); \
    Ame0 ^= De0; \
    Bgo1 = ROL32(Ame0, 22); \
    Ege1 =  Bge1 ^ ((~Bgi1)&  Bgo1 ); \
    Asi0 ^= Di0; \
    Bgu1 = ROL32(Asi0, 30); \
    Egi1 =  Bgi1 ^ ((~Bgo1)&  Bgu1 ); \
    Ego1 =  Bgo1 ^ ((~Bgu1)&  Bga1 ); \
    Egu1 =  Bgu1 ^ ((~Bga1)&  Bge1 ); \
\
    Abe1 ^= De1; \
    Bka0 = ROL32(Abe1,  1); \
    Agi0 ^= Di0; \
    Bke0 = ROL32(Agi0,  3); \
    Ako1 ^= Do1; \
    Bki0 = ROL32(Ako1, 13); \
    Eka0 =  Bka0 ^ ((~Bke0)&  Bki0 ); \
    Amu0 ^= Du0; \
    Bko0 = ROL32(Amu0,  4); \
    Eke0 =  Bke0 ^ ((~Bki0)&  Bko0 ); \
    Asa0 ^= Da0; \
    Bku0 = ROL32(Asa0,  9); \
    Eki0 =  Bki0 ^ ((~Bko0)&  Bku0 ); \
    Eko0 =  Bko0 ^ ((~Bku0)&  Bka0 ); \
    Eku0 =  Bku0 ^ ((~Bka0)&  Bke0 ); \
\
    Abe0 ^= De0; \
    Bka1 = Abe0; \
    Agi1 ^= Di1; \
    Bke1 = ROL32(Agi1,  3); \
    Ako0 ^= Do0; \
    Bki1 = ROL32(Ako0, 12); \
    Eka1 =  Bka1 ^ ((~Bke1)&  Bki1 ); \
    Amu1 ^= Du1; \
    Bko1 = ROL32(Amu1,  4); \
    Eke1 =  Bke1 ^ ((~Bki1)&  Bko1 ); \
    Asa1 ^= Da1; \
    Bku1 = ROL32(Asa1,  9); \
    Eki1 =  Bki1 ^ ((~Bko1)&  Bku1 ); \
    Eko1 =  Bko1 ^ ((~Bku1)&  Bka1 ); \
    Eku1 =  Bku1 ^ ((~Bka1)&  Bke1 ); \
\
    Abu1 ^= Du1; \
    Bma0 = ROL32(Abu1, 14); \
    Aga0 ^= Da0; \
    Bme0 = ROL32(Aga0, 18); \
    Ake0 ^= De0; \
    Bmi0 = ROL32(Ake0,  5); \
    Ema0 =  Bma0 ^ ((~Bme0)&  Bmi0 ); \
    Ami1 ^= Di1; \
    Bmo0 = ROL32(Ami1,  8); \
    Eme0 =  Bme0 ^ ((~Bmi0)&  Bmo0 ); \
    Aso0 ^= Do0; \
    Bmu0 = ROL32(Aso0, 28); \
    Emi0 =  Bmi0 ^ ((~Bmo0)&  Bmu0 ); \
    Emo0 =  Bmo0 ^ ((~Bmu0)&  Bma0 ); \
    Emu0 =  Bmu0 ^ ((~Bma0)&  Bme0 ); \
\
    Abu0 ^= Du0; \
    Bma1 = ROL32(Abu0, 13); \
    Aga1 ^= Da1; \
    Bme1 = ROL32(Aga1, 18); \
    Ake1 ^= De1; \
    Bmi1 = ROL32(Ake1,  5); \
    Ema1 =  Bma1 ^ ((~Bme1)&  Bmi1 ); \
    Ami0 ^= Di0; \
    Bmo1 = ROL32(Ami0,  7); \
    Eme1 =  Bme1 ^ ((~Bmi1)&  Bmo1 ); \
    Aso1 ^= Do1; \
    Bmu1 = ROL32(Aso1, 28); \
    Emi1 =  Bmi1 ^ ((~Bmo1)&  Bmu1 ); \
    Emo1 =  Bmo1 ^ ((~Bmu1)&  Bma1 ); \
    Emu1 =  Bmu1 ^ ((~Bma1)&  Bme1 ); \
\
    Abi0 ^= Di0; \
    Bsa0 = ROL32(Abi0, 31); \
    Ago1 ^= Do1; \
    Bse0 = ROL32(Ago1, 28); \
    Aku1 ^= Du1; \
    Bsi0 = ROL32(Aku1, 20); \
    Esa0 =  Bsa0 ^ ((~Bse0)&  Bsi0 ); \
    Ama1 ^= Da1; \
    Bso0 = ROL32(Ama1, 21); \
    Ese0 =  Bse0 ^ ((~Bsi0)&  Bso0 ); \
    Ase0 ^= De0; \
    Bsu0 = ROL32(Ase0,  1); \
    Esi0 =  Bsi0 ^ ((~Bso0)&  Bsu0 ); \
    Eso0 =  Bso0 ^ ((~Bsu0)&  Bsa0 ); \
    Esu0 =  Bsu0 ^ ((~Bsa0)&  Bse0 ); \
\
    Abi1 ^= Di1; \
    Bsa1 = ROL32(Abi1, 31); \
    Ago0 ^= Do0; \
    Bse1 = ROL32(Ago0, 27); \
    Aku0 ^= Du0; \
    Bsi1 = ROL32(Aku0, 19); \
    Esa1 =  Bsa1 ^ ((~Bse1)&  Bsi1 ); \
    Ama0 ^= Da0; \
    Bso1 = ROL32(Ama0, 20); \
    Ese1 =  Bse1 ^ ((~Bsi1)&  Bso1 ); \
    Ase1 ^= De1; \
    Bsu1 = ROL32(Ase1,  1); \
    Esi1 =  Bsi1 ^ ((~Bso1)&  Bsu1 ); \
    Eso1 =  Bso1 ^ ((~Bsu1)&  Bsa1 ); \
    Esu1 =  Bsu1 ^ ((~Bsa1)&  Bse1 ); \

#define lastRoundBebigokimisa(i) \
    Da0 = Cu0^ROL32(Ce1, 1); \
    Da1 = Cu1^Ce0; \
    De0 = Ca0^ROL32(Ci1, 1); \
    De1 = Ca1^Ci0; \
    Di0 = Ce0^ROL32(Co1, 1); \
    Di1 = Ce1^Co0; \
    Do0 = Ci0^ROL32(Cu1, 1); \
    Do1 = Ci1^Cu0; \
    Du0 = Co0^ROL32(Ca1, 1); \
    Du1 = Co1^Ca0; \
\
    Aba0 ^= Da0; \
    Bba0 = Aba0; \
    Age0 ^= De0; \
    Bbe0 = ROL32(Age0, 22); \
    Aki1 ^= Di1; \
    Bbi0 = ROL32(Aki1, 22); \
    Eba0 =  Bba0 ^ (  Bbe0 |  Bbi0 ); \
    Eba0 ^= KeccakRoundConstants0[i]; \
    Amo1 ^= Do1; \
    Bbo0 = ROL32(Amo1, 11); \
    Ebe0 =  Bbe0 ^ ((~Bbi0)|  Bbo0 ); \
    Asu0 ^= Du0; \
    Bbu0 = ROL32(Asu0,  7); \
    Ebi0 =  Bbi0 ^ (  Bbo0 &  Bbu0 ); \
    Ebo0 =  Bbo0 ^ (  Bbu0 |  Bba0 ); \
    Ebu0 =  Bbu0 ^ (  Bba0 &  Bbe0 ); \
\
    Aba1 ^= Da1; \
    Bba1 = Aba1; \
    Age1 ^= De1; \
    Bbe1 = ROL32(Age1, 22); \
    Aki0 ^= Di0; \
    Bbi1 = ROL32(Aki0, 21); \
    Eba1 =  Bba1 ^ (  Bbe1 |  Bbi1 ); \
    Eba1 ^= KeccakRoundConstants1[i]; \
    Amo0 ^= Do0; \
    Bbo1 = ROL32(Amo0, 10); \
    Ebe1 =  Bbe1 ^ ((~Bbi1)|  Bbo1 ); \
    Asu1 ^= Du1; \
    Bbu1 = ROL32(Asu1,  7); \
    Ebi1 =  Bbi1 ^ (  Bbo1 &  Bbu1 ); \
    Ebo1 =  Bbo1 ^ (  Bbu1 |  Bba1 ); \
    Ebu1 =  Bbu1 ^ (  Bba1 &  Bbe1 ); \
\
    Abo0 ^= Do0; \
    Bga0 = ROL32(Abo0, 14); \
    Agu0 ^= Du0; \
    Bge0 = ROL32(Agu0, 10); \
    Aka1 ^= Da1; \
    Bgi0 = ROL32(Aka1,  2); \
    Ega0 =  Bga0 ^ (  Bge0 |  Bgi0 ); \
    Ame1 ^= De1; \
    Bgo0 = ROL32(Ame1, 23); \
    Ege0 =  Bge0 ^ (  Bgi0 &  Bgo0 ); \
    Asi1 ^= Di1; \
    Bgu0 = ROL32(Asi1, 31); \
    Egi0 =  Bgi0 ^ (  Bgo0 |(~Bgu0)); \
    Ego0 =  Bgo0 ^ (  Bgu0 |  Bga0 ); \
    Egu0 =  Bgu0 ^ (  Bga0 &  Bge0 ); \
\
    Abo1 ^= Do1; \
    Bga1 = ROL32(Abo1, 14); \
    Agu1 ^= Du1; \
    Bge1 = ROL32(Agu1, 10); \
    Aka0 ^= Da0; \
    Bgi1 = ROL32(Aka0,  1); \
    Ega1 =  Bga1 ^ (  Bge1 |  Bgi1 ); \
    Ame0 ^= De0; \
    Bgo1 = ROL32(Ame0, 22); \
    Ege1 =  Bge1 ^ (  Bgi1 &  Bgo1 ); \
    Asi0 ^= Di0; \
    Bgu1 = ROL32(Asi0, 30); \
    Egi1 =  Bgi1 ^ (  Bgo1 |(~Bgu1)); \
    Ego1 =  Bgo1 ^ (  Bgu1 |  Bga1 ); \
    Egu1 =  Bgu1 ^ (  Bga1 &  Bge1 ); \
\
    Abe1 ^= De1; \
    Bka0 = ROL32(Abe1,  1); \
    Agi0 ^= Di0; \
    Bke0 = ROL32(Agi0,  3); \
    Ako1 ^= Do1; \
    Bki0 = ROL32(Ako1, 13); \
    Eka0 =  Bka0 ^ (  Bke0 |  Bki0 ); \
    Amu0 ^= Du0; \
    Bko0 = ROL32(Amu0,  4); \
    Eke0 =  Bke0 ^ (  Bki0 &  Bko0 ); \
    Asa0 ^= Da0; \
    Bku0 = ROL32(Asa0,  9); \
    Eki0 =  Bki0 ^ ((~Bko0)&  Bku0 ); \
    Eko0 = ~Bko0 ^ (  Bku0 |  Bka0 ); \
    Eku0 =  Bku0 ^ (  Bka0 &  Bke0 ); \
\
    Abe0 ^= De0; \
    Bka1 = Abe0; \
    Agi1 ^= Di1; \
    Bke1 = ROL32(Agi1,  3); \
    Ako0 ^= Do0; \
    Bki1 = ROL32(Ako0, 12); \
    Eka1 =  Bka1 ^ (  Bke1 |  Bki1 ); \
    Amu1 ^= Du1; \
    Bko1 = ROL32(Amu1,  4); \
    Eke1 =  Bke1 ^ (  Bki1 &  Bko1 ); \
    Asa1 ^= Da1; \
    Bku1 = ROL32(Asa1,  9); \
    Eki1 =  Bki1 ^ ((~Bko1)&  Bku1 ); \
    Eko1 = ~Bko1 ^ (  Bku1 |  Bka1 ); \
    Eku1 =  Bku1 ^ (  Bka1 &  Bke1 ); \
\
    Abu1 ^= Du1; \
    Bma0 = ROL32(Abu1, 14); \
    Aga0 ^= Da0; \
    Bme0 = ROL32(Aga0, 18); \
    Ake0 ^= De0; \
    Bmi0 = ROL32(Ake0,  5); \
    Ema0 =  Bma0 ^ (  Bme0 &  Bmi0 ); \
    Ami1 ^= Di1; \
    Bmo0 = ROL32(Ami1,  8); \
    Eme0 =  Bme0 ^ (  Bmi0 |  Bmo0 ); \
    Aso0 ^= Do0; \
    Bmu0 = ROL32(Aso0, 28); \
    Emi0 =  Bmi0 ^ ((~Bmo0)|  Bmu0 ); \
    Emo0 = ~Bmo0 ^ (  Bmu0 &  Bma0 ); \
    Emu0 =  Bmu0 ^ (  Bma0 |  Bme0 ); \
\
    Abu0 ^= Du0; \
    Bma1 = ROL32(Abu0, 13); \
    Aga1 ^= Da1; \
    Bme1 = ROL32(Aga1, 18); \
    Ake1 ^= De1; \
    Bmi1 = ROL32(Ake1,  5); \
    Ema1 =  Bma1 ^ (  Bme1 &  Bmi1 ); \
    Ami0 ^= Di0; \
    Bmo1 = ROL32(Ami0,  7); \
    Eme1 =  Bme1 ^ (  Bmi1 |  Bmo1 ); \
    Aso1 ^= Do1; \
    Bmu1 = ROL32(Aso1, 28); \
    Emi1 =  Bmi1 ^ ((~Bmo1)|  Bmu1 ); \
    Emo1 = ~Bmo1 ^ (  Bmu1 &  Bma1 ); \
    Emu1 =  Bmu1 ^ (  Bma1 |  Bme1 ); \
\
    Abi0 ^= Di0; \
    Bsa0 = ROL32(Abi0, 31); \
    Ago1 ^= Do1; \
    Bse0 = ROL32(Ago1, 28); \
    Aku1 ^= Du1; \
    Bsi0 = ROL32(Aku1, 20); \
    Esa0 =  Bsa0 ^ ((~Bse0)&  Bsi0 ); \
    Ama1 ^= Da1; \
    Bso0 = ROL32(Ama1, 21); \
    Ese0 = ~Bse0 ^ (  Bsi0 |  Bso0 ); \
    Ase0 ^= De0; \
    Bsu0 = ROL32(Ase0,  1); \
    Esi0 =  Bsi0 ^ (  Bso0 &  Bsu0 ); \
    Eso0 =  Bso0 ^ (  Bsu0 |  Bsa0 ); \
    Esu0 =  Bsu0 ^ (  Bsa0 &  Bse0 ); \
\
    Abi1 ^= Di1; \
    Bsa1 = ROL32(Abi1, 31); \
    Ago0 ^= Do0; \
    Bse1 = ROL32(Ago0, 27); \
    Aku0 ^= Du0; \
    Bsi1 = ROL32(Aku0, 19); \
    Esa1 =  Bsa1 ^ ((~Bse1)&  Bsi1 ); \
    Ama0 ^= Da0; \
    Bso1 = ROL32(Ama0, 20); \
    Ese1 = ~Bse1 ^ (  Bsi1 |  Bso1 ); \
    Ase1 ^= De1; \
    Bsu1 = ROL32(Ase1,  1); \
    Esi1 =  Bsi1 ^ (  Bso1 &  Bsu1 ); \
    Eso1 =  Bso1 ^ (  Bsu1 |  Bsa1 ); \
    Esu1 =  Bsu1 ^ (  Bsa1 &  Bse1 ); \

#ifdef UseBebigokimisa

#define lastRound(i) \
    lastRoundBebigokimisa(i)

#else

#define lastRound(i) \
    lastRoundNormal(i)

#endif
